package stack_test;

public class test1 {
}
class solution {
    public boolean validPalindrome(String s) {
        char[] arr = s.toCharArray();
        //使用双指针，从两边开始遍历
        int left = 0;
        int right = arr.length-1;
        int index = 1;
        while (right >= left){
            if(arr[left] == arr[right]){
                left++;
                right--;
            }
            if(index == 1){
                if(arr[left] != arr[right] && arr[++left] == arr[right]){
                    right--;
                    left++;
                }
                if(arr[left] != arr[right] && arr[left] == arr[--right]){
                    right--;
                    left++;
                }
                index ++;
                continue;
            }
            if(arr[left] != arr[right]){
                return false;
            }
        }
        return true;
    }
}
